<%--
  Created by IntelliJ IDEA.
  User: HW
  Date: 2024/12/20
  Time: 上午9:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.data.ConnData" %>
<%
    request.setCharacterEncoding("utf-8");
    // 获取要删除的笔记的id，这里假设通过GET方法传递，你可以根据实际情况修改
    String noteId = request.getParameter("note_id");
%>
    <%=noteId%>
<%
    ConnData objdata = new ConnData();
    Connection connection = null;
    PreparedStatement psmt = null;
    try {
        connection = objdata.getConn();
        String sql = "DELETE FROM note_table WHERE note_id =?";
        psmt = objdata.getPsmt(sql);
        psmt.setString(1, noteId);
        psmt.executeUpdate();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        if (psmt!= null) {
            try {
                psmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (connection!= null) {
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    // 删除成功后，重定向到原页面或者其他页面，这里假设重定向到原页面
    response.sendRedirect("conversation.jsp");
%>